
<form action="<?php echo U('Admin/Setting/Index/setDiscount')?>" id="form-data" method="post" class="_ajaxSubmit">
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">优惠卷金额<pub>*</pub> :</div>
        <div class="col-lg-2 col-md-2 col-xs-2 filed-from padding-none">
            <div class="input-group">
                <input type="text" name="price" data-type="price" class="form-control radius-none _data text-center" value="<?php echo $data['price'] ? $data['price'] : '0.00' ;?>" autocomplete="off">
                <span class="input-group-addon radius-none">&yen;</span>
            </div>
            <p style="margin-top: 5px;color:red;">为零则不发放优惠卷</p>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">优惠卷有效期<pub>*</pub> :</div>
        <div class="col-lg-2 col-md-2 col-xs-2 filed-from padding-none">
            <div class="input-group">
                <input type="text" name="time" data-type="int" class="form-control radius-none _data text-center" value="<?php echo $data['time'] ? $data['time'] : 0 ;?>" autocomplete="off">
                <span class="input-group-addon radius-none">天</span>
            </div>
            <p style="margin-top: 5px;color:red;">为零则不发放优惠卷</p>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">优惠卷张数<pub>*</pub> :</div>
        <div class="col-lg-2 col-md-2 col-xs-2 filed-from padding-none">
            <div class="input-group">
                <input type="text" name="nums" data-type="int" class="form-control radius-none _data text-center" value="<?php echo $data['nums'] ;?>" autocomplete="off">
                <span class="input-group-addon radius-none">张</span>
            </div>
            <p style="margin-top: 5px;color:red;">为零则不发放优惠卷</p>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">分类使用<pub>*</pub> :</div>
        <div class="col-lg-2 col-md-2 col-xs-2 filed-from padding-none">
            <div class="input-group">
                <select name="category" class="form-control _data">
                    <option value="0">全场通用</option>
                    <?php echo $category_tree;?>
                </select>
            </div>
            <p style="margin-top: 5px;color:red;">若不选,则全场通用</p>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 lists text-right">
        <input type="submit" name="dosubmit" value="保存" class="btn btn-success radius-none">
        <input type="reset"  value="重置" class="btn btn-info radius-none">
    </div>
</form>
<script>
    $(function(){

        $('._data','#form-data').blur(function(){

            var value = $(this).val();
            var type = $(this).data('type');

            if(type == 'int' ){

                if(Number(value) > 0){

                    $(this).val(Number(value))

                } else {

                    $(this).val(0)

                }

            }else if(type == 'price'){

                var val = !isNaN(parseFloat(value).toFixed(2)) ? parseFloat(value).toFixed(2) : '0.00' ;

                if(val > 0){

                    $(this).val(val);

                } else {

                    $(this).val('0.00');

                }

            }

        })

    })
    //表单异步提交回掉
    function ajaxRequestCallback(result,id)
    {

        switch(id){

            case 'form-data':

                showMessage(result.msg,result.code,'','',2000);

                break;

        }

    }
</script>